import request from "@/common/http";
import dictJson from './mock/dict.json'
import {DictItem} from "@/common/interfaces/system";

export async function queryDict(params?: any, useMock?: boolean) {
  if (useMock) {
    return Promise.resolve(dictJson)
  }
  return request('/api/sys/dict/list', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeDictOne(params: { id: number }) {
  return request('/api/sys/dict/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function removeDict(params: { ids: number[] }) {
  return request('/api/sys/dict/delete', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function addDict(params: DictItem) {
  return request('/api/sys/dict/add', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

export async function updateDict(params: DictItem) {
  return request('/api/sys/dict/update', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}
